// filepath: d:\workspaces\final_weather_app\lib\screens\home_screen.dart
import 'package:flutter/material.dart';

class HomeScreen extends StatelessWidget {
  const HomeScreen({super.key});

  @override
  Widget build(BuildContext context) {
    final List<Color> cardColors = [
      Colors.lightBlueAccent,
      Colors.purpleAccent,
      Colors.orangeAccent,
      Colors.greenAccent,
      Colors.pinkAccent,
      Colors.tealAccent,
    ];

    return Scaffold(
      appBar: AppBar(
        title: const Text('天气速览'),
        backgroundColor: Colors.deepPurpleAccent,
        elevation: 0,
      ),
      body: Container(
        decoration: const BoxDecoration(
          gradient: LinearGradient(
            colors: [Color(0xFFE3F2FD), Color(0xFFF8BBD0), Color(0xFFFFF9C4)],
            begin: Alignment.topLeft,
            end: Alignment.bottomRight,
          ),
        ),
        child: Padding(
          padding: const EdgeInsets.all(16.0),
          child: Column(
            children: [
              // 搜索框
              TextField(
                decoration: InputDecoration(
                  hintText: '请输入城市名称',
                  prefixIcon: Icon(Icons.search, color: Colors.deepPurpleAccent),
                  filled: true,
                  fillColor: Colors.white.withOpacity(0.8),
                  border: OutlineInputBorder(
                    borderRadius: BorderRadius.circular(16),
                    borderSide: BorderSide.none,
                  ),
                ),
              ),
              const SizedBox(height: 20),
              // 当前天气信息（彩色卡片）
              Card(
                color: Colors.orangeAccent.withOpacity(0.85),
                shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(18)),
                elevation: 8,
                child: ListTile(
                  leading: Icon(Icons.cloud, size: 44, color: Colors.white),
                  title: Text(
                    '当前城市：北京',
                    style: TextStyle(
                      color: Colors.white,
                      fontWeight: FontWeight.bold,
                      fontSize: 20,
                    ),
                  ),
                  subtitle: Text(
                    '晴  26°C  湿度: 40%',
                    style: TextStyle(color: Colors.white70, fontSize: 16),
                  ),
                ),
              ),
              const SizedBox(height: 20),
              // 未来7天天气预报（多彩卡片）
              Expanded(
                child: ListView.builder(
                  itemCount: 7,
                  itemBuilder: (context, index) {
                    final color = cardColors[index % cardColors.length];
                    return Card(
                      color: color.withOpacity(0.85),
                      shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
                      elevation: 6,
                      child: ListTile(
                        leading: Icon(Icons.wb_sunny, color: Colors.white, size: 36),
                        title: Text(
                          '6月${index + 10}日',
                          style: TextStyle(
                            color: Colors.white,
                            fontWeight: FontWeight.bold,
                          ),
                        ),
                        subtitle: Text(
                          '晴  最高30°C 最低20°C',
                          style: TextStyle(color: Colors.white70),
                        ),
                      ),
                    );
                  },
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}